package com.example.demo.service.serviceImpl;

import com.example.demo.dao.jdbc.PlcJDBCMapper;
import com.example.demo.dao.mybatis.PlcMybatisMapper;
import com.example.demo.pojo.PlcData;
import com.example.demo.service.PlcService;
import com.example.demo.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLException;

/**
 * plc业务实现类
 */
@Service
public class PlcServiceImpl implements PlcService {
    @Autowired
    PlcJDBCMapper plcJDBCMapper;
    @Autowired
    PlcMybatisMapper plcMybatisMapper;
    /**
     * 插入plc数据
     * @param plcData  plc数据
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public  String insert(PlcData plcData) {
        try {
            int num= plcJDBCMapper.insertPlc(plcData);
            if (num>0){
                System.out.println("插入成功" );
            }else{
                System.out.println("有错误，请排查" );
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return null;
    }
}
